package com.rickpan.dto.contacts;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Max;

/**
 * 用户搜索请求DTO
 */
public class UserSearchRequest {

    @NotBlank(message = "搜索关键词不能为空")
    @Size(min = 1, max = 50, message = "搜索关键词长度必须在1-50个字符之间")
    private String keyword;

    @NotNull(message = "搜索类型不能为空")
    private SearchType searchType = SearchType.ALL;

    private Boolean excludeFriends = true;

    @Min(value = 0, message = "页码不能小于0")
    private Integer page = 0;

    @Min(value = 1, message = "每页大小不能小于1")
    @Max(value = 50, message = "每页大小不能大于50")
    private Integer size = 10;

    // 搜索类型枚举
    public enum SearchType {
        USERNAME,    // 按用户名搜索
        EMAIL,       // 按邮箱搜索
        REAL_NAME,   // 按真实姓名搜索
        ALL          // 全部类型
    }

    // 构造函数
    public UserSearchRequest() {}

    public UserSearchRequest(String keyword) {
        this.keyword = keyword;
    }

    public UserSearchRequest(String keyword, SearchType searchType) {
        this.keyword = keyword;
        this.searchType = searchType;
    }

    // Getter和Setter方法
    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public SearchType getSearchType() {
        return searchType;
    }

    public void setSearchType(SearchType searchType) {
        this.searchType = searchType;
    }

    public Boolean getExcludeFriends() {
        return excludeFriends;
    }

    public void setExcludeFriends(Boolean excludeFriends) {
        this.excludeFriends = excludeFriends;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    @Override
    public String toString() {
        return "UserSearchRequest{" +
                "keyword='" + keyword + '\'' +
                ", searchType=" + searchType +
                ", excludeFriends=" + excludeFriends +
                ", page=" + page +
                ", size=" + size +
                '}';
    }
}
